# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=opendht-c
pkgver=v3.6.0.r1.g55ac11bf
pkgrel=1
epoch=1
pkgdesc='C++17 Distributed Hash Table implementation.'
arch=('x86_64' 'aarch64')
url='https://github.com/savoirfairelinux/opendht'
license=('GPL3')
depends=('argon2' 'asio' 'gnutls' 'jsoncpp' 'nettle' 'readline')
makedepends=('cmake' 'cython' 'fmt' 'git' 'http-parser' 'msgpack-cxx' 'python'
             'python-setuptools' 'restinio' 'samurai')
checkdepends=('cppunit-dev')
provides=('opendht')
conflicts=('opendht')
source=("git+https://github.com/savoirfairelinux/${pkgname%-c}.git")
sha512sums=('SKIP')

pkgver() {
  cd ${pkgname%-c}

  git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
  cd ${pkgname%-*}

  install -d build
}

build() {
  cd "${pkgname%-c}/build"

  cmake .. \
    -DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DOPENDHT_C=ON \
		-DOPENDHT_TOOLS=ON \
		-DOPENDHT_PYTHON=ON \
		-DOPENDHT_HTTP=ON \
		-DOPENDHT_PUSH_NOTIFICATIONS=ON \
		-DBUILD_TESTING="$(want_check && echo ON || echo OFF)" \
		$CMAKE_CROSSOPTS .

  make
}

package() {
  cd "${pkgname%-c}/build"

  make DESTDIR="$pkgdir" install

  install -Dm 644 -t "$pkgdir/usr/share/doc/opendht/" ../README.md
}

